#include <time.h>
#include <stdio.h>
#include <string.h>
#include "get_time.h"

time_t get_time_sec(int year)
{
	struct tm t;
	time_t tRet = 0;
	
	memset(&t, 0, sizeof(struct tm));
	
	t.tm_year = year;
     	t.tm_mon=0;
     	t.tm_mday=1;
     	t.tm_hour=0;
     	t.tm_min=0;
     	t.tm_sec=0;
     	t.tm_isdst=0;
 
	tRet = mktime(&t);
	
	return tRet;
}

int get_current_quarter()
{
	int m = 0;
	time_t t = 0;
	time_t current_t = 0;
	
	current_t = time(NULL);
	t = get_time_sec(START_TIME);

	m = ( t ) / ( 60 * 60 * 24 * 30 * 3 );
	
	return m;

}

int get_now_quarter()
{
	int m = 0;
	time_t current_t = 0;
	time_t t = 0;
	
	current_t = time(NULL);
	t = get_time_sec(START_TIME);
	
	m = (current_t - t ) / ( 60 * 60 * 24 * 30 * 3 );

	return m;
}
/*
int main()
{
	printf("Current quarter:%d\n",get_current_quarter());
	return 0;
}
*/
